package com.myinterview.intest;

public class StringProcessor {
    String inString = "";
    String outString = "";
    int processLength = 3;

    public StringProcessor(String rawString) {
        this.inString = rawString;
    }

    public String charProcessor(String inString, int currentIndex) {
        return null;
    }

    public String processor(String inString) {
        if (inString == null) {
            throw new IllegalArgumentException("in string should not be null");
        }
        int stringLength = inString.length();
        int lookupIndex = 0;
        boolean canProcess = false;
        for (int i = 0; i < stringLength; i++) {
            lookupIndex = i + processLength - 1;
            if (lookupIndex+1 > stringLength) {
                return outString;
            };

            for (int j = 1; j < processLength; j++) {
                if (inString.charAt(i) != inString.charAt(i+j)){
                    canProcess = false;
                    break;
                }
                canProcess = true;
            };
            if (canProcess) {
                outString = charProcessor(inString, i);
                break;
            }
        };
        return processor(outString);
    }

    public void getProcessString() {
        System.out.println("output value is:" + processor(inString));
    }
}